﻿<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="StyleSheet.css" />

    <!-- JavaScript -->
    <script src="https://code.jquery.com/jquery-3.2.1.min.js" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $.ajaxSetup({
                contentType: "application/json; charset=utf-8"
            });
            $('#buttonGet').click(function () {
                var id = $('#inputGrainId').val();
                $.get("api/values/" + id, function (value) {
                    console.log('GET Grain{' + id + "}=" + value);
                    $('#inputValue').val(value);
                });
                return false;
            });
            $('#buttonSet').click(function () {
                var id = $('#inputGrainId').val();
                var val = '"' + $('#inputValue').val() + '"';
                $.post("api/values/" + id, val, function () {
                    console.log('SET Grain{' + id + "}=" + val);
                });
                return false;
            });
        });
    </script>

    <title>Orleans + ASP.NET Core</title>
</head>
<body>
    <form class="form-values" action="">
        <div class="text-center mb-4">
            <h1 class="h3 mb-3 font-weight-normal">Value in Grains</h1>
        </div>
        <div class="form-label-group">
            <label for="inputGrainId">Grain ID</label>
            <input class="form-control" id="inputGrainId" autofocus="" required="" type="number" value="0">
        </div>
        <div class="form-label-group">
            <label for="inputValue">Value</label>
            <input class="form-control" id="inputValue" type="text">
        </div>
        <button id="buttonGet" class="btn btn-lg btn-primary btn-block" type="submit">Get Value</button>
        <button id="buttonSet" class="btn btn-lg btn-primary btn-block" type="submit">Set Value</button>
    </form>
</body>
</html>